package edu.ncst.baseweb.controller.resinfo;

import cn.wintersun.basecommon.common.Result;
import edu.ncst.baseweb.dao.Res;
import edu.ncst.baseweb.dao.res.ResInfo;
import edu.ncst.baseweb.service.intrer.resinfo.ResManageService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

//实验室预约管理
@RestController
@RequestMapping("/admin/boomanage/boomanage")
@PreAuthorize("hasAuthority('8')")
public class ResManageController {
    @Autowired
    private ResManageService resManageService;

    //实验室预约管理列表
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public Result<IPage<ResInfo>> list(@RequestBody ResInfo resInfo){

        return  resManageService.list(resInfo);
    }
    //预约信息发布
    @RequestMapping(value = "save",method = RequestMethod.POST)
    public Result<Object> save(@RequestBody Res res){
        try {
            return resManageService.save(res);
        } catch (Exception e) {
            return Result.failure(500, e.getMessage());
        }
    }
    //删除
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    public Result<Object> delete(@RequestBody String resid){
        try {
            return resManageService.delete(resid);
        } catch (Exception e) {
            return Result.failure(500, e.getMessage());
        }
    }

}
